# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Alessio 'mOLOk' Bolognino <themolok@gmail.com>
# Contributor: daniel g. siegel <dgsiegel@gmail.com>

pkgname=libsmbios
pkgver=2.4.1
pkgrel=2
pkgdesc="A library for providing access to as much BIOS information as possible"
arch=('x86_64')
url="https://github.com/dell/libsmbios"
license=('GPL' 'custom')
depends=('gcc-libs')
makedepends=('libxml2' 'python' 'chrpath' 'doxygen' git cppunit help2man)
optdepends=('python: tools')
_commit=465dce1b625f11f38698aec3b5f48751b85f0942  # tags/v2.4.1^0
source=("git+https://github.com/dell/libsmbios.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname
  ./autogen.sh --no-configure
}

build() {
  unset MAKEFLAGS
  cd $pkgname
  mkdir build
  cd build
  ../configure --prefix=/usr --sbindir=/usr/bin --sysconfdir=/etc --disable-static
  make
}

package() {
  cd $pkgname/build
  make DESTDIR="${pkgdir}" install

  chrpath -d "${pkgdir}/usr/bin/smbios-sys-info-lite"
  install -m755 -d "${pkgdir}/usr/include"

  cp -a ../src/include/* "${pkgdir}/usr/include/"
  cp -a out/public-include/* "${pkgdir}/usr/include/"

  install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -m644 ../COPYING-OSL "${pkgdir}/usr/share/licenses/${pkgname}/"
}
